package com.hd.manager.util;

import org.springframework.stereotype.Component;

import javax.crypto.SecretKey;
import java.security.SecureRandom;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * @projectName:    entrance_guard 
 * @package:        com.hd.manager.util
 * @className:      RequestIdUtil
 * @author:     otto
 * @description:  
 * @date:    2023/7/25 17:02
 * @version:    1.0
 */ 


public class RequestIdUtil {
    public static Long getRequestId(){
        Date now = new Date();
        Long nowLong = now.getTime();
        Long lastSeven = nowLong&Long.valueOf(127);
        Long radomThree = Long.valueOf(new Random().nextInt(900)+100);
        Long res = lastSeven*1000+radomThree;
        return res;
//        Random random = new Random();
//        String nanoRandom = System.nanoTime() + "" + random.nextInt(99999);
//        int hash = Math.abs(UUID.randomUUID().hashCode());
//        int needAdd = 19 - String.valueOf(hash).length() + 1;
//        return Long.valueOf(hash + "" + nanoRandom.substring(needAdd));

    }
}
